a86050
@@ -428,7 +428,7 @@
private void analyzeGrant(ASTNode ast) throws SemanticException {
         if (astChild.getType() == HiveParser.TOK_GRANT_WITH_OPTION) {
           grantOption = true;
         } else if (astChild.getType() == HiveParser.TOK_PRIV_OBJECT) {
-          privilegeObj = analyzePrivilegeObject(astChild);
+          privilegeObj = analyzePrivilegeObject(astChild, getOutputs());
         }
       }
     }
@@ -453,7 +453,7 @@
private void analyzeRevoke(ASTNode ast) throws SemanticException {
     PrivilegeObjectDesc hiveObj = null;
     if (ast.getChildCount() > 2) {
       ASTNode astChild = (ASTNode) ast.getChild(2);
-      hiveObj = analyzePrivilegeObject(astChild);
+      hiveObj = analyzePrivilegeObject(astChild, getOutputs());
     }
 
     RevokeDesc revokeDesc = new RevokeDesc(privilegeDesc, principalDesc, hiveObj);
@@ -462,7 +462,8 @@
private void analyzeRevoke(ASTNode ast) throws SemanticException {
   }
 
 
-  private PrivilegeObjectDesc analyzePrivilegeObject(ASTNode ast)
+  private PrivilegeObjectDesc analyzePrivilegeObject(ASTNode ast,
+      HashSet<WriteEntity> outputs)
       throws SemanticException {
     PrivilegeObjectDesc subject = new PrivilegeObjectDesc();
     subject.setObject(unescapeIdentifier(ast.getChild(0).getText()));
@@ -476,6 +477,21 @@
private PrivilegeObjectDesc analyzePrivilegeObject(ASTNode ast)
         }
       }
     }
+
+    try {
+      if (subject.getTable()) {
+        Table tbl = db.getTable(subject.getObject());
+        if (subject.getPartSpec() != null) {
+          Partition part = db.getPartition(tbl, subject.getPartSpec(), false);
+          outputs.add(new WriteEntity(part));
+        } else {
+          outputs.add(new WriteEntity(tbl));
+        }
+      }
+    } catch (HiveException e) {
+      throw new SemanticException(e);
+    }
+
     return subject;
   }
 
@@ -513,7 +529,7 @@
private PrivilegeObjectDesc analyzePrivilegeObject(ASTNode ast)
       Privilege privObj = PrivilegeRegistry.getPrivilege(privilegeType.getType());
 
       if (privObj == null) {
-        throw new SemanticException("undefined privilege " + privObj.toString());
+        throw new SemanticException("undefined privilege " + privilegeType.getType());
       }
       List<String> cols = null;
       if (privilegeDef.getChildCount() > 1) {
